package com.antaohua.tools.api.factory;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import com.antaohua.tools.api.interfaces.CallApiInterface;

public class CallFactory {

	@Autowired
	private List<CallApiInterface> calls;
	
	
	public CallApiInterface getCall(String code){
		CallApiInterface call = null;
		for (CallApiInterface callApiInterface : calls) {
			if(callApiInterface.getCode().equals(code.trim())){
				call = callApiInterface;
				break;
			}
		}
		return call;
	}
	
	
	public List<String> getCallCodes(){
		List<String> result = new ArrayList<>(); 
		for (CallApiInterface callApiInterface : calls) {
			result.add(callApiInterface.getCode());
		}
		return result;
	}
}
